package com.ruoyi.usermes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.usermes.domain.CmfUsermes;
import com.ruoyi.usermes.service.ICmfUsermesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员信息Controller
 *
 * @author layh
 * @date 2024-06-12
 */
@RestController
@RequestMapping("/usermes/usermes")
public class CmfUsermesController extends BaseController
{
    @Autowired
    private ICmfUsermesService cmfUsermesService;

    /**
     * 查询人员信息列表
     */
   // @PreAuthorize("@ss.hasPermi('usermes:usermes:list')")
    @GetMapping("/list")
    public TableDataInfo list(CmfUsermes cmfUsermes)
    {
        startPage();
        List<CmfUsermes> list = cmfUsermesService.selectCmfUsermesList(cmfUsermes);
        return getDataTable(list);
    }

    /**
     * 导出人员信息列表
     */
   // @PreAuthorize("@ss.hasPermi('usermes:usermes:export')")
    @Log(title = "人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmfUsermes cmfUsermes)
    {
        List<CmfUsermes> list = cmfUsermesService.selectCmfUsermesList(cmfUsermes);
        ExcelUtil<CmfUsermes> util = new ExcelUtil<CmfUsermes>(CmfUsermes.class);
        util.exportExcel(response, list, "人员信息数据");
    }

    /**
     * 获取人员信息详细信息
     */
   // @PreAuthorize("@ss.hasPermi('usermes:usermes:query')")
    @GetMapping(value = "/{Id}")
    public AjaxResult getInfo(@PathVariable("Id") Integer Id)
    {
        return success(cmfUsermesService.selectCmfUsermesById(Id));
    }

    /**
     * 新增人员信息
     */
   // @PreAuthorize("@ss.hasPermi('usermes:usermes:add')")
    @Log(title = "人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmfUsermes cmfUsermes)
    {
        return toAjax(cmfUsermesService.insertCmfUsermes(cmfUsermes));
    }

    /**
     * 修改人员信息
     */
    //@PreAuthorize("@ss.hasPermi('usermes:usermes:edit')")
    @Log(title = "人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmfUsermes cmfUsermes)
    {
        return toAjax(cmfUsermesService.updateCmfUsermes(cmfUsermes));
    }

    /**
     * 删除人员信息
     */
    @PreAuthorize("@ss.hasPermi('usermes:usermes:remove')")
    @Log(title = "人员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{Ids}")
    public AjaxResult remove(@PathVariable Integer[] Ids)
    {
        return toAjax(cmfUsermesService.deleteCmfUsermesByIds(Ids));
    }

    @GetMapping("/lay")
    public int lay (){
        System.out.println(123);
        return 200;
    }
}
